<?php
    header("Content-type:text/html;charset=utf-8");
    include "Model.php";
    echo "<pre>";
    $conn =new Mysql('preferredshares','oc_user_org');
       
    $sql  = 'select  uid as client_id , equity , createtime as create_time ,equity_time as confirm_time,ic.id as init_comp_id, cm.id as management_id 
       from oc_user_org as o
       left join client_management        as cm on  o.uid = cm.client_id  
       left join client_initiator_company as ic on  o.uid = ic.client_id  and ic.client_id =cm.client_id
       where type=4'; 
    $res =$conn->getAll($sql);
    //var_dump($res);
    //exit;
    $conn1 =  new Mysql('preferredshares','client_partner'); 
    foreach ($res as $k =>$v){
        $data =array();
        $data['client_id']       =$v['client_id'];
        $data['confirm_time']    =$v['confirm_time'];
        $data['create_time']     =$v['create_time']==0 ? Null:date('Y-m-d H:i:s',$v['create_time']);
        $data['init_comp_id']    =$v['init_comp_id'];
        $data['management_id']   =$v['management_id'];
        $data['is_management']   =isset($v['management_id'])?1:0;
        $data['update_time']     =Null;
        $data['is_qualified']    =$v['equity']==Null ? 0 : 1;
        //var_dump($data);
        //exit;
        //$res=$conn1->insert($data);
    }
    echo '<script>alert("插入数据库成功")</script>';